﻿using System;
using System.Web.Security;
using System.Web.UI.WebControls;
using METU_CMT.Business;

namespace METU_CMT
{
    public partial class LoginScreen : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            
        }

        protected void OnLnkBtnPasswordRecoveryClicked(object sender, EventArgs e)
        {
            Response.Redirect("~/PasswordRecoveryScreen.aspx");
        }

        protected void OnBtnLoginClicked(object sender, EventArgs e)
        {
            User _user = EntityFactory.GetUser(txtUsername.Text, txtPassword.Text);
            if(_user == null)
            {
                MsgBox1.alert("Wrong Username or Password");
                //CommonMethods.GoToLoginScreen( Response );
                return;
            }

            FormsAuthentication.SetAuthCookie(_user.UserName, false); // Kalıcı cookie yaratımı false ile engelleniyor
            _user.GoToProfilePage(Response);
        }
    }
}